package com.lin.generator;

import com.lin.model.DataModel;
import freemarker.template.TemplateException;

import java.io.File;
import java.io.IOException;
public class MainGenerator {
    public static void doGenerator(DataModel dataModel) throws TemplateException, IOException {
        String inputRootPath = "source/project";
        String outputRootPath = "generated";
        String inputPath;
        String outputPath;
            boolean needGit = dataModel.needGit;
            boolean loop = dataModel.loop;
                String author = dataModel.mainTemplate.author;
                String output = dataModel.mainTemplate.output;
        // groupKey = git
            if(needGit) {
               inputPath = new File(inputRootPath, "src/com/lin/acm/MainTemplate.java.ftl").getAbsolutePath();
               outputPath = new File(outputRootPath, "src/com/lin/acm/MainTemplate.java").getAbsolutePath();
                   DynamicFileGenerator.doGenerator(inputPath, outputPath, dataModel);
               inputPath = new File(inputRootPath, ".gitignore").getAbsolutePath();
               outputPath = new File(outputRootPath, ".gitignore").getAbsolutePath();
                   StaticFileGenerator.CopyFileByHutool(inputPath, outputPath);
            }
           inputPath = new File(inputRootPath, "README.md").getAbsolutePath();
           outputPath = new File(outputRootPath, "README.md").getAbsolutePath();
               StaticFileGenerator.CopyFileByHutool(inputPath, outputPath);
    }
}
